package ink.lovejinhu.leetcode;

import org.junit.Test;

/**
 * @author jinhu
 * created 2021-05-06 17:58
 */
public class Solution_0069 {
    public int mySqrt(int x) {
        if (x == 0 || x == 1) {
            return x;
        }
        for (int i = 1; i < x / 2+1; i++) {
            if (x / i >= i && x / (i + 1) < (i + 1)) {
                return i;
            }
        }
        return 0;
    }

    @Test
    public void test() {
        int i = this.mySqrt(2);
        System.out.println(i);
    }
}
